﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogicServer.Bugs;
using LogicServer;

namespace BugSysSolution.DataManagement
{
    public partial class EditPosts : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindTypeList();
                BindBugList(Convert.ToInt32(ddl1.SelectedItem.Value));
            }
        }

        public void BindBugList(int index)
        {
            BugLogic bl = new BugLogic();
            this.rep1.DataSource = bl.GetBugsByType(index);
            this.rep1.DataBind();
        }

        public void BindTypeList()
        {
            BugTypesLogic bl = new BugTypesLogic();
            ddl1.DataSource = bl.GetAllType();
            ddl1.DataValueField = "TypeId";
            ddl1.DataTextField = "TypeText";
            ddl1.DataBind();
        }

        protected void ddl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            BindBugList(Convert.ToInt32(ddl1.SelectedItem.Value));
        }

        protected void btn_search_Click(object sender, EventArgs e)
        {
            BugLogic bl = new BugLogic();
            String name = this.txt_bugname.Text.Trim();
            this.rep1.DataSource = bl.SearchBugList(name);
            this.rep1.DataBind();
        }
    }
}